home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!news
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Rogue Wave bug? / How buggy is Rogue Wave?
- Date: 8 Jan 1996 18:49:09 GMT
- Organization: Datalytics, Inc
- Message-ID: <4crov6$h4r@gold.datalytics.com>
- References: <DKo7KB.6KL@unx.sas.com>
- NNTP-Posting-Host: pc071.datalytics.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- sasrag@ramanujn.unx.sas.com (Russell Gonsalves) wrote:
- >/*
- >
- >Here's the program to try:
- >
- >The bug?
- >
- >It seems to badly handle null-strings. The last
- >print still prints yy. While test.isNull() is
- >aware that the string is a null-terminated string,
-
- Actually, isNull() is only aware that the string has a length
- of zero. That difference is the crux of the problem as
- explained below.
-
- >such a RWCString cast to const char * does not
- >point to "". This appears to defeat the otherwise
- >seamless and elegant conversion between RWCStrings
- >and character pointers.
- >
- >If you have RW could you try this out, and tell
- >me if your version produces similar results.
- >
- I have Tools.h++ v6.1 and I got similar results. I was
- surprised at the behavior. Here is the relevent code from the
- implementation. The problem is that, since there is no other
- RWCString referencing the same RWCStringRef, operator = only
- sets nchars_ (the number of characters in the string) to zero.
- It should also assign a null terminator to data_[0].
-
- RWCString&
- RWCString::operator=(const char* cs)
- {
- [snip]
- if (pref()->references() == 1) {
- pref()->nchars_ = 0;
- // should also include this statement:
- *data_ = '\0';
- } else {
- [snip]
- }
- return *this;
- [snip]
- }
-
-
- >What are your experiences with this library. We've
- >just started to use it, and quite frankly I'm a
- >little surprised by this bug.
- >
- I have nothing (until now) but praise for the Tools.h++
- library. They have done many slick things with the language
- (consider the RWCSubString extraction using function call
- syntax on an RWCString), and have implemented sound, complete,
- and properly OO classes.
-
- I regularly use RWCString and haven't encountered a problem
- with the incorrect behavior you observed. That doesn't mean I
- won't. It is a wise purchase. You will readily recoup the
- cost in enhanced productivity.
-
- Despite this problem, I would still recommend the library. If
- you buy rights to the source code, as we have, you can make
- this fix yourself (not that you should have to, mind you).
-
- >#include <iostream.h>
- >#include <rw/cstring.h>
- >
- >static void print(const char * p)
- >{
- > cout << "String:\"" << p << "\"" << endl;
- >}
- >
- >main()
- >{
- > RWCString test;
- >
- > test = "abc";
- > print(test);
- > test = "xyz";
- > print(test);
- > test = "yy";
- > print(test);
- > test = "";
- > print(test);
- >}
- >
-
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc.
- (513)226-7700
- stew@datalytics.com
-
-
-